module  Control
  class DictsController < BaseController
    before_action :set_dict, only: [:edit, :update, :destroy]

    def index
      @dicts = current_user.dicts.order(created_at: :desc)
    end

    def new
      @dict = Dict.new
      render layout: false
    end

    def edit
      render layout: false
    end

    def create
      @dict = current_user.dicts.new(dict_params)
      @dict.save
    end

    def update
      @dict.update(dict_params)
    end

    def destroy
      @dict.destroy
    end

    private
    def set_dict
      @dict = current_user.dicts.find(params[:id])
    end

    def dict_params
      params.require(:dict).permit(:name)
    end
  end
end
